home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 5212 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.5 KB

  1. Path: lrz-muenchen.de!news
  2. From: watzka@stat.uni-muenchen.de (Kurt Watzka)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Random Numbers Help Needed
  5. Date: 8 Feb 1996 18:40:45 GMT
  6. Organization: Leibniz-Rechenzentrum, Muenchen (Germany)
  7. Distribution: world
  8. Message-ID: <4fdg3d$n24@sparcserver.lrz-muenchen.de>
  9. References: <4facsd$lch@bagan.srce.hr>
  10. NNTP-Posting-Host: sun2.lrz-muenchen.de
  11.  
  12. ov30801@tilia.cc.fer.hr (oliver-marin vidovic) writes:
  13.  
  14.  
  15. > Hi! I have a problem involving random number generator.
  16. > In my program I need a list of random numbers, but I don't want
  17. >them to be the same every time I start the program. Now, I know I
  18. >have to change the seed by srand function, but if I put the argument 
  19. >to be constant, then srand is of no use. Therefore, i came to conclusion
  20. >that i have to make the argument of srand every time different. 
  21. > So, my idea was to use the computer clock somehow, and to take
  22. >time as the seed, since that can hardly be the same every time I
  23. >start the program. But, there is something wrong when I try to make
  24. >something with functions from time.h.
  25. >(maybe I don't use them in right way, or maybe the whole idea is wrong)
  26.  
  27. The idea is quite good, so it must be the way you use time().
  28.  
  29. >Is there someone who can help me?!
  30.  
  31. Probably, yes, but probably not without seeing the source of your
  32. atempt to seed the random number generator.
  33.  
  34. Kurt
  35. --
  36. | Kurt Watzka                             Phone : +49-89-2180-6254
  37. | watzka@stat.uni-muenchen.de
  38. | ua302aa@sunmail.lrz-muenchen.de
  39.